package com.xpxrule.controller.manage;

import com.xpxrule.dataobject.biz.model.ReturnResponse;
import com.xpxrule.dataobject.req.EnumConstantQueryReq;
import com.xpxrule.dataobject.vo.OptionVo;
import com.xpxrule.dataobject.vo.EnumConstantVo;
import com.xpxrule.service.EnumConstantService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/enumConstant")
public class EnumConstantController {
    @Autowired
    private EnumConstantService enumConstantService;

    /**
     * 新增枚举常量
     * @param vo
     * @return
     */
    @PostMapping("/insert")
    public ReturnResponse<Integer> insert(@RequestBody EnumConstantVo vo) {
        return enumConstantService.insert(vo);
    }

    /**
     * 根据id删除枚举常量
     * @param id
     * @return
     */
    @GetMapping("/delete/{id}")
    public ReturnResponse<Integer> delete(@PathVariable("id") Long id) {
        return enumConstantService.delete(id);
    }

    /**
     * 根据id更新枚举常量
     * @param vo
     * @return
     */
    @PostMapping("/update")
    public ReturnResponse<Integer> update(@RequestBody EnumConstantVo vo) {
        return enumConstantService.update(vo);
    }

    /**
     * 根据查询条件查询枚举常量
     * @param req
     * @return
     */
    @PostMapping("/select/byQuery")
    public ReturnResponse<List<EnumConstantVo>> selectList(@RequestBody EnumConstantQueryReq req) {
        return enumConstantService.selectList(req);
    }

    /**
     * 获取所有枚举常量下拉选项
     * @return
     */
    @GetMapping("/get/all/enumConstant/options")
    public ReturnResponse<List<OptionVo>> getAllEnumConstantOptions() {
        return enumConstantService.getAllEnumConstantOptions();
    }
}
